<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template name="client-info">
	<xsl:param name="tomorrow">
		<xsl:call-template name="next-day">
			<xsl:with-param name="date" select="$today"/>
		</xsl:call-template>
	</xsl:param>
	
	<dl id="apt_next">
		<dt>Next Appointment</dt>
		<xsl:choose>
			<xsl:when test="/data/future-client-appointments-short/error = 'No records found.'">
				<dd><em>No Appointments Yet</em></dd>
				<dd>Making an appointment is easy! Click the day of the month for the appointment, then select a desired time.</dd>
			</xsl:when>
			<xsl:otherwise>
				<xsl:for-each select="/data/future-client-appointments-short/entry[1]">
					<dd>
						<em>
							<img src="{$workspace}/css/img/icon_next_apt.png" alt="Your next appointment" title="Your next appointment" />
							<xsl:call-template name="get-formatted-date">
								<xsl:with-param name="date" select="appointment-date"/>
								<xsl:with-param name="format-type" select="'short'"/>
							</xsl:call-template>
							<xsl:text>, </xsl:text>
							<xsl:call-template name="get-formatted-time">
								<xsl:with-param name="time" select="appointment-date/@time"/>
							</xsl:call-template>
						</em>
					</dd>
				</xsl:for-each>
			</xsl:otherwise>
		</xsl:choose>
	</dl>
	
	<xsl:choose>
		<xsl:when test="not(/data/future-client-appointments-short/error)">
			<dl id="apts_future">
				<dt>Future Appointments</dt>
				<xsl:for-each select="/data/future-client-appointments-short/entry">
					<dd>
						<form id="delete-apt-{@id}" action="" method="post">
							<em>
								<a href="{$root}/calendar/day/{substring(appointment-date,1,4)}/{substring(appointment-date,6,2)}/{substring(appointment-date,9,2)}">
									<xsl:call-template name="get-formatted-date">
										<xsl:with-param name="date" select="appointment-date"/>
										<xsl:with-param name="format-type" select="'short'"/>
									</xsl:call-template>
									<xsl:text>, </xsl:text>
									<xsl:call-template name="get-formatted-time">
										<xsl:with-param name="time" select="appointment-date/@time"/>
									</xsl:call-template>
								</a>
									<xsl:if test="appointment-date != $today and appointment-date != $tomorrow">
										<input name="id" value="{@id}" type="hidden" />
										<input class="cancel-apt" name="action[delete-apt]" type="image" src="{$root}/workspace/images/delete.png" value="Cancel Appointment" />
									</xsl:if>
							</em>
						</form>
					</dd>
				</xsl:for-each>
			</dl>
		</xsl:when>
	</xsl:choose>
	
	<xsl:choose>
		<xsl:when test="not(/data/past-client-appointments-short/error)">
			<dl id="apts_past">
				<dt>Past Appointments</dt>
				<xsl:for-each select="/data/past-client-appointments-short/entry[appointment-date != $today]">
					<dd>
						<img src="{$workspace}/css/img/icon_{payment-status/item/@handle}.gif" title="{payment-status/item}" alt="payment-status/item"/>
						<em>
							<!--a href="{$root}/archives/" title="Appointment {payment-status/item}"-->
							<xsl:call-template name="get-formatted-date">
								<xsl:with-param name="date" select="appointment-date"/>
								<xsl:with-param name="format-type" select="'short'"/>
							</xsl:call-template>
							<xsl:text>, </xsl:text>
							<xsl:call-template name="get-formatted-time">
								<xsl:with-param name="time" select="appointment-date/@time"/>
							</xsl:call-template>
						</em>
					</dd>
				</xsl:for-each>
				<dd><a href="{$root}/archives" title="View all past appointments">View All</a></dd>
			</dl>
		</xsl:when>
	</xsl:choose>
	
</xsl:template>

</xsl:stylesheet>